/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.mallsite.modules.shop.entity;

import java.util.Date;

import org.hibernate.validator.constraints.NotBlank;

import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.JoinTable.Type;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;

/**
 * 商品Entity
 * @author ruyang
 * @version 2020-12-04
 */
@Table(name="ms_goods", alias="a", columns={
		@Column(name="goods_id", attrName="goodsId", label="商品id", isPK=true),
		@Column(name="category_code", attrName="category.categoryCode", label="分类id"),
		@Column(name="extend_category_code", attrName="extendCategory.categoryCode", label="扩展分类id"),
		@Column(name="goods_sn", attrName="goodsSn", label="商品编号"),
		@Column(name="goods_name", attrName="goodsName", label="商品名称", queryType=QueryType.LIKE),
		@Column(name="click_count", attrName="clickCount", label="点击数"),
		@Column(name="brand_id", attrName="brandId", label="品牌id"),
		@Column(name="store_count", attrName="storeCount", label="库存数量"),
		@Column(name="comment_count", attrName="commentCount", label="商品评论数"),
		@Column(name="weight", attrName="weight", label="商品重量克为单位"),
		@Column(name="volume", attrName="volume", label="商品体积。单位立方米"),
		@Column(name="market_price", attrName="marketPrice", label="市场价"),
		@Column(name="shop_price", attrName="shopPrice", label="本店价"),
		@Column(name="cost_price", attrName="costPrice", label="商品成本价"),
		@Column(name="price_ladder", attrName="priceLadder", label="价格阶梯"),
		@Column(name="keywords", attrName="keywords", label="商品关键词"),
		@Column(name="goods_summary", attrName="goodsSummary", label="商品简单描述"),
		@Column(name="goods_content", attrName="goodsContent", label="商品详细描述"),
		@Column(name="mobile_content", attrName="mobileContent", label="手机端商品详情"),
		@Column(name="goods_logo", attrName="goodsLogo", label="商品上传原始图"),
		@Column(name="is_virtual", attrName="isVirtual", label="是否为虚拟商品 1是，0否"),
		@Column(name="virtual_indate", attrName="virtualIndate", label="虚拟商品有效期"),
		@Column(name="virtual_limit", attrName="virtualLimit", label="虚拟商品购买上限"),
		@Column(name="virtual_refund", attrName="virtualRefund", label="是否允许过期退款， 1是，0否"),
		@Column(name="is_on_sale", attrName="isOnSale", label="是否上架 0-未上架 1-销售中"),
		@Column(name="is_free_shipping", attrName="isFreeShipping", label="是否包邮0否1是"),
		@Column(name="on_time", attrName="onTime", label="商品上架时间"),
		@Column(name="goods_sort", attrName="goodsSort", label="商品排序"),
		@Column(name="is_recommend", attrName="isRecommend", label="是否推荐0-未推荐 1-已推荐"),
		@Column(name="is_new", attrName="isNew", label="是否新品0-不是 1-是"),
		@Column(name="is_hot", attrName="isHot", label="是否热卖"),
		@Column(name="goods_type", attrName="goodsType", label="商品所属类型id，取值表goods_type的id"),
		@Column(name="spec_type", attrName="specType", label="商品规格类型，取值表goods_type的id"),
		@Column(name="give_integral", attrName="giveIntegral", label="购买商品赠送积分"),
		@Column(name="exchange_integral", attrName="exchangeIntegral", label="积分兑换"),
		@Column(name="suppliers_id", attrName="suppliersId", label="供货商ID"),
		@Column(name="sales_sum", attrName="salesSum", label="商品销量"),
		@Column(name="prom_type", attrName="promType", label="0默认1抢购2团购3优惠促销4预售5虚拟"),
		@Column(name="prom_id", attrName="promId", label="优惠活动id"),
		@Column(name="commission", attrName="commission", label="佣金用于分销分成"),
		@Column(name="spu", attrName="spu", label="SPU"),
		@Column(name="sku", attrName="sku", label="SKU"),
		@Column(name="template_id", attrName="templateId", label="运费模板ID"),
		@Column(name="goods_video", attrName="goodsVideo", label="视频"),
		@Column(name="shop_id", attrName="shop.shopId", label="店铺编码"),
		@Column(name="unit", attrName="unit", label="单位"),
		@Column(includeEntity=DataEntity.class),
	}, joinTable = {
			@JoinTable(type=Type.LEFT_JOIN, entity = GoodsCategory.class, attrName = "category", alias = "c",
					on = "c.category_code = a.category_code", columns = {
						@Column(name = "category_name", attrName = "categoryName"),
					}),
			@JoinTable(type=Type.LEFT_JOIN, entity = GoodsCategory.class, attrName = "extendCategory", alias = "cc",
				on = "cc.category_code = a.extend_category_code", columns = {
					@Column(name = "category_name", attrName = "categoryName"),
				}),
			@JoinTable(type=Type.LEFT_JOIN, entity = Shop.class, alias = "s",
				on = "s.shop_id = a.shop_id", columns = {
					@Column(name = "shop_id"),
					@Column(name = "shop_name"),
				})
			}, orderBy="a.goods_sort ASC, a.update_date DESC"
)
public class Goods extends DataEntity<Goods> {
	
	private static final long serialVersionUID = 1L;
	private String goodsId;		// 商品id
//	private Long categoryCode;		// 分类id
//	private Long extendCategoryCode;		// 扩展分类id
	private String goodsSn;		// 商品编号
	private String goodsName;		// 商品名称
	private Integer clickCount;		// 点击数
	private Integer brandId;		// 品牌id
	private Integer storeCount;		// 库存数量
	private Integer commentCount;		// 商品评论数
	private Long weight;		// 商品重量克为单位
	private Double volume;		// 商品体积。单位立方米
	private Double marketPrice;		// 市场价(零售价)
	private Double shopPrice;		// 本店价(供货价)
	private Double costPrice;		// 商品成本价
	private String priceLadder;		// 价格阶梯
	private String keywords;		// 商品关键词
	private String goodsSummary;		// 商品简单描述
	private String goodsContent;		// 商品详细描述
	private String mobileContent;		// 手机端商品详情
	private String goodsLogo;		// 商品上传原始图(主图)
	private Integer isVirtual;		// 是否为虚拟商品 1是，0否
	private Long virtualIndate;		// 虚拟商品有效期
	private Integer virtualLimit;		// 虚拟商品购买上限
	private Integer virtualRefund;		// 是否允许过期退款， 1是，0否
	private Integer isOnSale;		// 是否上架 0-未上架 1-销售中
	private Integer isFreeShipping;		// 是否包邮0否1是
	private Date onTime;		// 商品上架时间
	private Integer goodsSort;		// 商品排序
	private Integer isRecommend;		// 是否推荐0-未推荐 1-已推荐
	private Integer isNew;		// 是否新品0-不是 1-是
	private Integer isHot;		// 是否热卖
	private Integer goodsType;		// 商品所属类型id，取值表goods_type的id
	private Integer specType;		// 商品规格类型，取值表goods_type的id
	private Integer giveIntegral;		// 购买商品赠送积分
	private Integer exchangeIntegral;		// 积分兑换：0不参与积分兑换，积分和现金的兑换比例见后台配置
	private Integer suppliersId;		// 供货商ID
	private Long salesSum;		// 商品销量
	private Integer promType;		// 0默认1抢购2团购3优惠促销4预售5虚拟(5其实没用)6拼团
	private Long promId;		// 优惠活动id
	private Double commission;		// 佣金用于分销分成
	private String spu;		// SPU
	private String sku;		// SKU
	private Long templateId;		// 运费模板ID
	private String goodsVideo;		// 视频
	private String shopId;		// shop_id
	private String unit;
	
	private GoodsCategory category;
	private GoodsCategory extendCategory;
	
	private Shop shop;
	
	public Goods() {
		this(null);
	}

	public Goods(String id){
		super(id);
	}
	
	public String getGoodsId() {
		return goodsId;
	}

	public void setGoodsId(String goodsId) {
		this.goodsId = goodsId;
	}
	
//	@NotNull(message="分类id不能为空")
//	public Long getCategoryCode() {
//		return categoryCode;
//	}
//
//	public void setCategoryCode(Long categoryCode) {
//		this.categoryCode = categoryCode;
//	}
//	
//	public Long getExtendCategoryCode() {
//		return extendCategoryCode;
//	}
//
//	public void setExtendCategoryCode(Long extendCategoryCode) {
//		this.extendCategoryCode = extendCategoryCode;
//	}
	
	public String getGoodsSn() {
		return goodsSn;
	}

	public void setGoodsSn(String goodsSn) {
		this.goodsSn = goodsSn;
	}
	
	@NotBlank(message="商品名称不能为空")
	public String getGoodsName() {
		return goodsName;
	}

	public void setGoodsName(String goodsName) {
		this.goodsName = goodsName;
	}
	
	public Integer getClickCount() {
		return clickCount;
	}

	public void setClickCount(Integer clickCount) {
		this.clickCount = clickCount;
	}
	
	public Integer getBrandId() {
		return brandId;
	}

	public void setBrandId(Integer brandId) {
		this.brandId = brandId;
	}
	
	public Integer getStoreCount() {
		return storeCount;
	}

	public void setStoreCount(Integer storeCount) {
		this.storeCount = storeCount;
	}
	
	public Integer getCommentCount() {
		return commentCount;
	}

	public void setCommentCount(Integer commentCount) {
		this.commentCount = commentCount;
	}
	
	public Long getWeight() {
		return weight;
	}

	public void setWeight(Long weight) {
		this.weight = weight;
	}
	
	public Double getVolume() {
		return volume;
	}

	public void setVolume(Double volume) {
		this.volume = volume;
	}
	
	public Double getMarketPrice() {
		return marketPrice;
	}

	public void setMarketPrice(Double marketPrice) {
		this.marketPrice = marketPrice;
	}
	
	public Double getShopPrice() {
		return shopPrice;
	}

	public void setShopPrice(Double shopPrice) {
		this.shopPrice = shopPrice;
	}
	
	public Double getCostPrice() {
		return costPrice;
	}

	public void setCostPrice(Double costPrice) {
		this.costPrice = costPrice;
	}
	
	public String getPriceLadder() {
		return priceLadder;
	}

	public void setPriceLadder(String priceLadder) {
		this.priceLadder = priceLadder;
	}
	
	public String getKeywords() {
		return keywords;
	}

	public void setKeywords(String keywords) {
		this.keywords = keywords;
	}
	
	public String getGoodsSummary() {
		return goodsSummary;
	}

	public void setGoodsSummary(String goodsSummary) {
		this.goodsSummary = goodsSummary;
	}
	
	public String getGoodsContent() {
		return goodsContent;
	}

	public void setGoodsContent(String goodsContent) {
		this.goodsContent = goodsContent;
	}
	
	public String getMobileContent() {
		return mobileContent;
	}

	public void setMobileContent(String mobileContent) {
		this.mobileContent = mobileContent;
	}
	
	public String getGoodsLogo() {
		return goodsLogo;
	}

	public void setGoodsLogo(String goodsLogo) {
		this.goodsLogo = goodsLogo;
	}
	
	public Integer getIsVirtual() {
		return isVirtual;
	}

	public void setIsVirtual(Integer isVirtual) {
		this.isVirtual = isVirtual;
	}
	
	public Long getVirtualIndate() {
		return virtualIndate;
	}

	public void setVirtualIndate(Long virtualIndate) {
		this.virtualIndate = virtualIndate;
	}
	
	public Integer getVirtualLimit() {
		return virtualLimit;
	}

	public void setVirtualLimit(Integer virtualLimit) {
		this.virtualLimit = virtualLimit;
	}
	
	public Integer getVirtualRefund() {
		return virtualRefund;
	}

	public void setVirtualRefund(Integer virtualRefund) {
		this.virtualRefund = virtualRefund;
	}
	
	public Integer getIsOnSale() {
		return isOnSale;
	}

	public void setIsOnSale(Integer isOnSale) {
		this.isOnSale = isOnSale;
	}
	
	public Integer getIsFreeShipping() {
		return isFreeShipping;
	}

	public void setIsFreeShipping(Integer isFreeShipping) {
		this.isFreeShipping = isFreeShipping;
	}
	
	public Date getOnTime() {
		return onTime;
	}

	public void setOnTime(Date onTime) {
		this.onTime = onTime;
	}
	
	public Integer getGoodsSort() {
		return goodsSort;
	}

	public void setGoodsSort(Integer goodsSort) {
		this.goodsSort = goodsSort;
	}
	
	public Integer getIsRecommend() {
		return isRecommend;
	}

	public void setIsRecommend(Integer isRecommend) {
		this.isRecommend = isRecommend;
	}
	
	public Integer getIsNew() {
		return isNew;
	}

	public void setIsNew(Integer isNew) {
		this.isNew = isNew;
	}
	
	public Integer getIsHot() {
		return isHot;
	}

	public void setIsHot(Integer isHot) {
		this.isHot = isHot;
	}
	
	public Integer getGoodsType() {
		return goodsType;
	}

	public void setGoodsType(Integer goodsType) {
		this.goodsType = goodsType;
	}
	
	public Integer getSpecType() {
		return specType;
	}

	public void setSpecType(Integer specType) {
		this.specType = specType;
	}
	
	public Integer getGiveIntegral() {
		return giveIntegral;
	}

	public void setGiveIntegral(Integer giveIntegral) {
		this.giveIntegral = giveIntegral;
	}
	
	public Integer getExchangeIntegral() {
		return exchangeIntegral;
	}

	public void setExchangeIntegral(Integer exchangeIntegral) {
		this.exchangeIntegral = exchangeIntegral;
	}
	
	public Integer getSuppliersId() {
		return suppliersId;
	}

	public void setSuppliersId(Integer suppliersId) {
		this.suppliersId = suppliersId;
	}
	
	public Long getSalesSum() {
		return salesSum;
	}

	public void setSalesSum(Long salesSum) {
		this.salesSum = salesSum;
	}
	
	public Integer getPromType() {
		return promType;
	}

	public void setPromType(Integer promType) {
		this.promType = promType;
	}
	
	public Long getPromId() {
		return promId;
	}

	public void setPromId(Long promId) {
		this.promId = promId;
	}
	
	public Double getCommission() {
		return commission;
	}

	public void setCommission(Double commission) {
		this.commission = commission;
	}
	
	public String getSpu() {
		return spu;
	}

	public void setSpu(String spu) {
		this.spu = spu;
	}
	
	public String getSku() {
		return sku;
	}

	public void setSku(String sku) {
		this.sku = sku;
	}
	
	public Long getTemplateId() {
		return templateId;
	}

	public void setTemplateId(Long templateId) {
		this.templateId = templateId;
	}
	
	public String getGoodsVideo() {
		return goodsVideo;
	}

	public void setGoodsVideo(String goodsVideo) {
		this.goodsVideo = goodsVideo;
	}
	
	public String getShopId() {
		return shopId;
	}

	public void setShopId(String shopId) {
		this.shopId = shopId;
	}

	public GoodsCategory getCategory() {
		if (category == null) {
			category = new GoodsCategory();
		}
		return category;
	}

	public void setCategory(GoodsCategory category) {
		this.category = category;
	}

	public Shop getShop() {
		return shop;
	}

	public void setShop(Shop shop) {
		this.shop = shop;
	}

	public String getUnit() {
		return unit;
	}

	public void setUnit(String unit) {
		this.unit = unit;
	}

	public GoodsCategory getExtendCategory() {
		if (extendCategory == null) {
			extendCategory = new GoodsCategory();
		}
		return extendCategory;
	}

	public void setExtendCategory(GoodsCategory extendCategory) {
		this.extendCategory = extendCategory;
	}
	
}